import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import IndexUser from '../views/IndexUser.vue'
import IndexAdmin from '../views/admin/IndexAdmin'
import BlogType from '../views/admin/BlogType'
import UserType from '../views/admin/UserType'
import IllegalOperation from '../views/admin/IllegalOperation'
import Feedback from '../views/admin/Feedback'
import Test from '../views/Test'
import PublishArticle from '../views/PublishArticle'
import Index from '../views/Index'
import PersonalHomePage from '../views/PersonalHomePage'
import UserArticles from '../views/UserArticles'
import ShareArticles from '../views/ShareArticles'
import MyAttention from '../views/MyAttention'
import MyFans from '../views/MyFans'
import EditData from '../views/EditData'
import ViewedUserHomePage from '../views/ViewedUserHomePage'
import HisAttention from '../views/HisAttention'
import HisUserArticles from '../views/HisUserArticles'
import HisFans from '../views/HisFans'
import HisShareArticles from '@/views/HisShareArticles'
import detailPage from '@/views/detailPage'
import CommentPage from '@/views/CommentPage'
import Error from '@/views/Error'

const routes = [
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/indexUser',
    name: 'IndexUser',
    component: IndexUser,
    redirect: '/index',
    children: [
      {
        path: '/publishArticle',
        name: 'PublishArticle',
        component: PublishArticle
      },
      {
        path: '/index',
        name: 'Index',
        component: Index
      },
      {
        path: '/personalHomePage',
        name: 'PersonalHomePage',
        component: PersonalHomePage,
        children: [
          {
            path: '/userArticles',
            name: 'UserArticles',
            component: UserArticles,
            hidden: true
          },
          {
            path: '/myAttention',
            name: 'MyAttention',
            component: MyAttention
          },
          {
            path: '/myFans',
            name: 'MyFans',
            component: MyFans
          },
          {
            path: '/shareArticles',
            name: 'ShareArticles',
            component: ShareArticles
          }
        ],
        redirect: '/userArticles'
      },
      {
        path: '/editData',
        name: 'EditData',
        component: EditData
      },
      {
        path: '/viewedUserHomePage',
        name: 'ViewedUserHomePage',
        component: ViewedUserHomePage,
        children: [
          {
            path: '/hisUserArticles',
            name: 'HisUserArticles',
            component: HisUserArticles,
            hidden: true
          },
          {
            path: '/hisAttention',
            name: 'HisAttention',
            component: HisAttention
          },
          {
            path: '/hisFans',
            name: 'HisFans',
            component: HisFans
          },
          {
            path: '/hisShareArticles',
            name: 'HisShareArticles',
            component: HisShareArticles
          }
        ],
        redirect: '/hisUserArticles'
      },
      {
        path: '/detailPage',
        name: 'DetailPage',
        component: detailPage
      },
      {
        path: '/commentPage',
        name: 'CommentPage',
        component: CommentPage
      },
      {
        path: '/error',
        name: 'Error',
        component: Error
      }
    ]
  },
  {
    path: '/test',
    name: 'Test',
    component: Test
  },
  {
    path: '/indexAdmin',
    name: 'IndexAdmin',
    component: IndexAdmin,
    children: [
      {
        path: '/blogType',
        name: 'BlogType',
        component: BlogType
      },
      {
        path: '/userType',
        name: 'UserType',
        component: UserType
      },
      {
        path: '/feedback',
        name: 'Feedback',
        component: Feedback
      },
      {
        path: '/illegalOperation',
        name: 'IllegalOperation',
        component: IllegalOperation
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
